package com.example.adapter

import android.graphics.Color
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.example.image.ImgLoader
import com.example.image.option.ImageOptions
import com.example.image.skill.ImageLoader
import com.zhpan.bannerview.BannerViewPager


/**
 * 绑定的所需的适配器
 */
object CommBindingAdapter {

    @JvmStatic
    @BindingAdapter("imageUrl")
    fun loadUrlImage(imageView : ImageView, url : String){
        if (!url.isNullOrEmpty()){
            ImgLoader.build().loadNetIntoImageView(imageView.context,url,imageView, ImageOptions.setCommonImage(true).build())
        }
    }


    @JvmStatic
    @BindingAdapter("imageCircleUrl")
    fun loadUrlCircleImage(imageView : ImageView, url : String){
        if (!url.isNullOrEmpty()){
            ImgLoader.build().loadNetIntoImageView(imageView.context,url,imageView, ImageOptions.setCircleImage(true).build())
        }
    }

    @JvmStatic
    @BindingAdapter("bgcolor")
    fun loadBgColor(imageView: ImageView,colorStr:String){
        if (!colorStr.isNullOrEmpty()){
            imageView.setBackgroundColor(Color.parseColor(colorStr))
        }
    }


}